package com.gamex.findit.internal;

import java.net.InetAddress;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gamex.findit.Constants;
import com.gamex.findit.battle.BattleServer;

@Service
public  class DefaultConfig implements InitializingBean, DisposableBean{
	
	private static final Logger logger = LoggerFactory.getLogger(DefaultConfig.class);
	private String hostAddress;
	
	
	@Autowired BattleServer findItServer;

	@Override
	public void destroy() throws Exception {
		findItServer.destroy();
		
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		//InetAddress localAddr = InetAddress.getLocalHost();
		logger.info("----------------------------------------------");
		logger.info("Init server config...");
		logger.info("----------------------------------------------");
		
		setHostAddress(Constants.SERVER_ADDRESS);
		
		/* 소켓 서버 스타트  */
		findItServer.initBattleServer();
	
       
	}
	
	public String getHostAddress() {
		return hostAddress;
	}

	public void setHostAddress(String hostAddress) {
		this.hostAddress = hostAddress;
	}

}
